using System.Collections;
using System.Collections.Generic;
using Script.SteerBehaviour;
using TMPro;
using UnityEngine;

public abstract class MIniPeopleBase : MonoBehaviour
{
    public float oscillationFrequency = 1f;
    public float strenthX = 1;
    public float strenthY = 1;
    private Rigidbody2D rb;
    public GameObject chatBox;
    public GameObject bar;
    public TextMeshPro text;
    
    protected virtual void Awake()
    {
        rb = GetComponent<Rigidbody2D>();
    }

    protected virtual void Start()
    {
        StartCoroutine(Jump());
    }
    public IEnumerator Seek(GameObject target)
    {
        while (true)
        {
            SteerBehaviour steerBehaviour = GetComponent<SteerBehaviour>();
            Vector3 accler = steerBehaviour.Seek(target.transform.position);
            steerBehaviour.Steer(accler);
            yield return new WaitForFixedUpdate();
        }
    }
    IEnumerator Jump()
    {
        while (true)
        {
            rb.AddForce(new Vector2(strenthX,strenthY),ForceMode2D.Impulse);
            yield return new WaitForSeconds(oscillationFrequency);
        }
    }
    
    
}
